{ INFORMATICS.MCCME.RU
  Problem statement: http://informatics.mccme.ru/moodle/mod/statements/view3.php?chapterid=753
  Verdict: Accepted
}
uses 
	SysUtils, Math;
 
var  	
	q,qq,n,tp,x,l,r,count,cc:longint;
	comp,first,last,cnt:array[0..400010] of int64;
 
function can(i,l,r,tl,tr:longint):boolean;
 
var
	tm:longint;
 
begin
if comp[i]>0 then begin
	result:=false;
	exit;
end;
if (l=tl) and (r=tr) then begin
	if cnt[i]>0 then result:=false else result:=true;
	exit;
end;
tm:=(tl+tr) shr 1;
if r<=tm then result:=can(2*i,l,r,tl,tm) else
if l>tm then result:=can(2*i+1,l,r,tm+1,tr) else 
	result:=can(2*i,l,tm,tl,tm) and can(2*i+1,tm+1,r,tm+1,tr);
end;
 
procedure make(i,l,r,tl,tr:longint);
 
var
	tm:longint;
 
begin
inc(cnt[i]);
if (l=tl) and (r=tr) then comp[i]:=count else begin
	tm:=(tr+tl) shr 1;
	if r<=tm then make(2*i,l,r,tl,tm) else 
	if l>tm then make(2*i+1,l,r,tm+1,tr) else begin
		make(2*i,l,tm,tl,tm);
		make(2*i+1,tm+1,r,tm+1,tr);
	end;
end;
end;
 
function find(i,tl,tr,x:longint):longint;
 
var
	tm:longint;
 
begin
if comp[i]>0 then begin
	result:=comp[i];
	exit;
end;
if tl=tr then begin
	result:=0;
	exit;
end;
tm:=(tl+tr) shr 1;
if x<=tm then result:=find(2*i,tl,tm,x) else result:=find(2*i+1,tm+1,tr,x);
end;
 
procedure del(i,l,r,tl,tr:longint);
 
var
	tm:longint;
 
begin
dec(cnt[i]);
if (l=tl) and (r=tr) then comp[i]:=0 else begin
	tm:=(tl+tr) shr 1;
	if r<=tm then del(2*i,l,r,tl,tm) else 
	if l>tm then del(2*i+1,l,r,tm+1,tr) else begin
		del(2*i,l,tm,tl,tm);
		del(2*i+1,tm+1,r,tm+1,tr);
	end;	
end;
end;
 
begin
reset(input,'input.txt');
rewrite(output,'output.txt');
read(n,q);
for qq:=1 to q do begin
	read(tp);
	if tp=1 then begin
		read(l,r);
		if can(1,l,r,1,n) then begin
			writeln(1);
			inc(count);
			first[count]:=l;
			last[count]:=r;
			make(1,l,r,1,n);
		end else writeln(0);
	end else begin
		read(x);
		cc:=find(1,1,n,x);
		writeln(first[cc],' ',last[cc]);
		if cc>0 then del(1,first[cc],last[cc],1,n);
	end;
end;
end.